Add protection for xenpm access power management info
authorKeir Fraser <keir.fraser@citrix.com>
Tue, 21 Oct 2008 08:48:08 +0000 (09:48 +0100)
committerKeir Fraser <keir.fraser@citrix.com>
Tue, 21 Oct 2008 08:48:08 +0000 (09:48 +0100)
Signed-off-by: Liu Jinsong <jinsong.liu@intel.com>
xen/drivers/acpi/pmstat.c
xen/drivers/cpufreq/utility.c

index b3ba34c378bc84cf64fdbe653074cfed442a3911..42051d20709d75bd02f0bb9aeb29b875a2b8632d 100644 (file)
@@ -52,7 +52,7 @@ int do_get_pm_info(struct xen_sysctl_get_pmstat *op)
     int ret = 0;
     const struct processor_pminfo *pmpt;
 
-    if ( (op->cpuid >= NR_CPUS) || !cpu_online(op->cpuid) )
+    if ( !op || (op->cpuid >= NR_CPUS) || !cpu_online(op->cpuid) )
         return -EINVAL;
     pmpt = processor_pminfo[op->cpuid];
 
@@ -87,7 +87,7 @@ int do_get_pm_info(struct xen_sysctl_get_pmstat *op)
         uint64_t tmp_idle_ns;
         struct pm_px *pxpt = cpufreq_statistic_data[op->cpuid];
 
-        if ( !pxpt )
+        if ( !pxpt || !pxpt->u.pt || !pxpt->u.trans_pt )
             return -ENODATA;
 
         total_idle_ns = get_cpu_idle_time(op->cpuid);
index a26e2518c35d419c87f051fc20ccb264a9abada1..b9330c1de2c9539fbc47e8185365bb28cf7b3aaf 100644 (file)
@@ -129,7 +129,7 @@ void cpufreq_statistic_reset(unsigned int cpuid)
     struct pm_px *pxpt = cpufreq_statistic_data[cpuid];
     const struct processor_pminfo *pmpt = processor_pminfo[cpuid];
 
-    if ( !pxpt || !pmpt )
+    if ( !pmpt || !pxpt || !pxpt->u.pt || !pxpt->u.trans_pt )
         return;
 
     count = pmpt->perf.state_count;